Namespace.Use("Application.UI.Navigator", function(ns) {
    var Locale = Namespace.Import("Locale");


    //  Fast translation function.
    function _(path) {
        return Locale.Management.LoadMessage("Application.UI.Navigator." + path);
    }

    var g_SensorMenuItems = [
    ];

    var g_PageMap = {

    };
    var Page = Namespace.Import("Application.UI.Page");

    var Sensor = Namespace.Import("Application.Sensor");


    (function() {
        var pages = Page.Sensors.GetPages();
        for (var page_id = 0; page_id < pages.length; ++page_id) {
            var page = pages[page_id];
            var page_nav = "sensors/" + page["Title"];
            g_SensorMenuItems.push({
                "text": page.Title,
                "id": page_nav
            });
            g_PageMap[page_nav] = page["Object"];
        }
    })();


    var cst_JSTreeConfiguration = {
        "core" : {
            "data": [
                {
                    "id": "index",
                    "text": _("Index")
                },
                {
                    "text": _("Sensors"),
                    "children": g_SensorMenuItems/*[
                        {
                            "id": "sensors/distance",
                            "text": _("Distance")
                        },
                        {
                            "id": "sensors/accelerometer",
                            "text": _("Accelerometer")
                        }
                    ]*/,
                    "state": {
                        "opened": true
                    }
                },
                {
                    "text": _("Multimedia"),
                    "children": [
                        {
                            "id": "multimedia/camera",
                            "text": _("Camera")
                        }
                    ],
                    "state": {
                        "opened": true
                    }
                },
                {
                    "id": "about",
                    "text": _("About")
                }
            ],
            "themes": {
                "name": "tmm-navigator",
                "variant": "large",
                "icons": false,
            },
            "animation": false,
            "multiple": false
        },
        "plugins": [
            "wholerow"
        ]
    };


    function GetJSTreeConfiguration() {
        return cst_JSTreeConfiguration;
    }

    var GetMappedPage = Polymorphic.Create(
        [String],
        function(key) {
            if (key in g_PageMap) {
                return g_PageMap[key];
            } else {
                return null;
            }
        }
    );

    Namespace.Export(ns, "GetJSTreeConfiguration", GetJSTreeConfiguration);
    Namespace.Export(ns, "GetMappedPage", GetMappedPage);
});
